#include "Device/tft/TFT_RT1064.h"

/*需要配置引脚数量较多，其余引脚直接写在代码中,不做初始化参数*/

void TFT_RT1064::LCD_RES_Clr()
{
    GPIO_PinWrite(GPIO3, 26U, 0);
}
void TFT_RT1064::LCD_RES_Set()
{
    GPIO_PinWrite(GPIO3, 26U, 1);
}
void TFT_RT1064::LCD_DC_Clr()
{
    GPIO_PinWrite(GPIO1, 2U, 0);
}
void TFT_RT1064::LCD_DC_Set()
{
    GPIO_PinWrite(GPIO1, 2U, 1);
}
void TFT_RT1064::LCD_CS_Clr()
{
    GPIO_PinWrite(GPIO2, 13U, 0);
}
void TFT_RT1064::LCD_CS_Set()
{
    GPIO_PinWrite(GPIO2, 13U, 1);
}
/*void TFT_RT1064::LCD_BLK_Clr()
{

}
void TFT_RT1064::LCD_BLK_Set()
{

}*/
void TFT_RT1064::LCD_Writ_Bus(uint8_t dat)
{
    masterXfer.txData = &dat;
    masterXfer.rxData = NULL;
    masterXfer.dataSize = 1;
    masterXfer.configFlags =
         kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;
    LCD_CS_Clr();
    LPSPI_MasterTransferBlocking(base, &masterXfer);
    LCD_CS_Set();
}
void TFT_RT1064::LCD_WR_DATA(uint16_t dat)
{
    uint8_t data[2];
    data[0] = dat >> 8;
    data[1] = dat;
    masterXfer.txData = data;
    masterXfer.rxData = NULL;
    masterXfer.dataSize = 2;
    masterXfer.configFlags =
         kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;
    LCD_CS_Clr();
    LPSPI_MasterTransferBlocking(base, &masterXfer);
    LCD_CS_Set();
}

